package Service;

import Dao.UserDao;
import domain.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;
import java.util.Map;
import java.util.Properties;

public class UserServiceImpl implements UserService{
    private UserDao userDao;

    public UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }

    public UserServiceImpl() {
    }

    public void setUserDao(UserDao userDao){
        this.userDao=userDao;
    }
    @Override
    public void save() {
        ApplicationContext applicationContext = new
                ClassPathXmlApplicationContext("applicationContext.xml");
        UserDao userDao1 = (UserDao) applicationContext.getBean("userDao");
        userDao1.save();

    }

    public void save1(){
        userDao.save();
        System.out.println(this);
    }

    private String company;
    private int age;
    // 一定要有set方法
    public void setCompany(String company) {
        this.company = company;
    }
    public void setAge(int age) {
        this.age = age;
    }
    private List<String> strList;
    public void setStrList(List<String> strList) {
        this.strList = strList;
    }
    private List<User> userList;
    public void setUserList(List<User> userList) {
        this.userList = userList;
    }

    private Map<String,User> userMap;
    public void setUserMap(Map<String, User> userMap) {
        this.userMap = userMap;
    }

    private Properties properties;
    public void setProperties(Properties properties) {
        this.properties = properties;
    }

    @Override
    public String toString() {
        return "UserServiceImpl{" +
                "userDao=" + userDao +
                ", company='" + company + '\'' +
                ", age=" + age +
                ", strList=" + strList +
                ", userList=" + userList +
                ", userMap=" + userMap +
                ", properties=" + properties +
                '}';
    }
}
